/*
 * BBActionEnd.java
 *
 * Created on March 21, 2008, 10:54 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package hextd.blackBox;

import hextd.core.Context;
import hextd.message.MessageGameEnd;

/**
 *
 * @author hylke
 */
public class BBActionEnd implements BBAction {

	private static final BlackBox.ActionType type = BlackBox.ActionType.End;
	private int gameTime;
	private int player;

	/** Creates a new instance of BBActionEnd */
	public BBActionEnd(int gameTime, int player) {
		this.gameTime = gameTime;
		this.player = player;
	}

	@Override
	public BlackBox.ActionType getType() {
		return BBActionEnd.type;
	}

	@Override
	public int getGameTime() {
		return this.gameTime;
	}

	@Override
	public void execute(Context c) {
		//System.out.println("BBActionEnd::execute: "+c.gameTime+" Ending replay");
		if (!c.getBlackBox().endGame(gameTime, false)) {
			System.err.println("BBActionEnd::execute: Sync error: Ending replay failed!");
		}
	}

	@Override
	public String getString() {
		return MessageGameEnd.formatMessage(player, gameTime);
	}
}
